/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package br.com.tmd.controlefinanceiro.modelo;

import java.io.Serializable;
import java.util.List;
import java.util.Objects;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author luis
 */
@Entity
@Table(name = "conta")
public class Conta implements Serializable{
    
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column
    private Integer id;
    
    @Column
    private String codigo;
    
    @Column(nullable = false, length = 255)
    private String descricao;
    
    @Column(nullable = false)
    private Double saldo;
    /*
    @OneToMany(targetEntity = Pagamento.class)
    @JoinColumn(name = "id_pagamento")
    private List<Pagamento> pagamentos;
    */
    public Conta() {
    }

    public Conta(Integer id, String codigo, String descricao, Double saldo) {
        this.id = id;
        this.codigo = codigo;
        this.descricao = descricao;
        this.saldo = saldo;
    }
    
    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getDescricao() {
        return descricao;
    }

    public void setDescricao(String descricao) {
        this.descricao = descricao;
    }
    
        public String getCodigo() {
        return codigo;
    }

    public void setCodigo(String codigo) {
        this.codigo = codigo;
    }

    public Double getSaldo() {
        return saldo;
    }

    public void setSaldo(Double saldo) {
        this.saldo = saldo;
    }
    /*
    public List<Pagamento> getPagamento() {
        return pagamentos;
    }

    public void setPagamento(List<Pagamento> pagamentos) {
        this.pagamentos = pagamentos;
    }
    */
    @Override
    public int hashCode() {
        int hash = 5;
        hash = 83 * hash + Objects.hashCode(this.id);
        hash = 83 * hash + Objects.hashCode(this.codigo);
        hash = 83 * hash + Objects.hashCode(this.descricao);
        hash = 83 * hash + Objects.hashCode(this.saldo);
       // hash = 83 * hash + Objects.hashCode(this.pagamentos);
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Conta other = (Conta) obj;
        if (!Objects.equals(this.id, other.id)) {
            return false;
        }
        if (!Objects.equals(this.codigo, other.codigo)) {
            return false;
        }
        if (!Objects.equals(this.descricao, other.descricao)) {
            return false;
        }
        if (!Objects.equals(this.saldo, other.saldo)) {
            return false;
        }/*
        if (!Objects.equals(this.pagamentos, other.pagamentos)) {
            return false;
        }*/
        return true;
    }

    @Override
    public String toString() {
        return "Conta{" + "id=" + id + ", descricao=" + descricao + ", codigo=" + codigo + ", saldo=" + saldo + '}';
    }
    
}
